// ==UserScript==
// @include	   http://*.imvu.com/catalog/modules.php?op=modload&name=phpbb2&file=posting.php*
// @include	   http://*.imvu.com/catalog/modules.php?op=modload&name=phpbb2&file=privmsg
// ==/UserScript==
window.addEventListener('DOMContentLoaded', function() {
     if ( widget.preferences.forp == "enabled" ){
	var nl = document.createElement("input");
	nl.setAttribute('type', 'button');
	nl.setAttribute('style', 'width: 55px');
	nl.setAttribute('value', 'N URL');
	nl.setAttribute('name', 'cusbbnl');
	nl.setAttribute('class', 'button');
	var nl2 = document.createElement("input");
	nl2.setAttribute('type', 'button');
	nl2.setAttribute('style', 'width: 64px');
	nl2.setAttribute('value', 'Img Link');
	nl2.setAttribute('name', 'cusbbn2');
	nl2.setAttribute('class', 'button');
	document.getElementsByName("addbbcode14")[0].parentNode.appendChild(nl2);
	document.getElementsByName("addbbcode16")[0].parentNode.appendChild(nl);
	nl2.addEventListener("click", imfu_cusimglink2, false);
	nl.addEventListener("click", imfu_cusnamelink2, false);
	}
}, true);

function imfu_cusnamelink2(){
var lvalue = document.getElementsByName("message")[0];
var lurl = prompt("Enter Link", "");
if(lurl==null) { return; }
var lname = prompt("Enter Name", "");
if(lname==null) { return; }
else { lvalue.value = lvalue.value += "[url="+lurl+"]"+lname+"[/url]" }
} 

function imfu_cusimglink2(){
var lvalue = document.getElementsByName("message")[0];
var liurl = prompt("Enter Link", "");
if(liurl==null) { return; } 
var liname = prompt("Enter Image Link", "");
if(liname==null) { return; } 
else { lvalue.value = lvalue.value += "[url="+liurl+"][img]"+liname+"[/img][/url]" } 
}